<?php

namespace app\index\controller;

use app\common\controller\Frontend;
use think\Db;

class Index extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function index()
    {
        $beian = [
            'www.douyimei.top'=>2,
            'www.lairui.top'=>1,
            'lairui.top'=>1
        ];
        $beian_num = 0;
        foreach ($beian as $k => $v) {
            if ($_SERVER['HTTP_HOST'] == $k) {
                $beian_num = $v;
            }
        }

        $this->assign('beian',$beian_num);

        return $this->view->fetch();
        $history = Db::name('content')->order('time desc')->column('name','id');
        $month = ['1'=>'一月','2'=>'二月','3'=>'三月','4'=>'四月','5'=>'五月','6'=>'六月','7'=>'七月','8'=>'八月','9'=>'九月','10'=>'十月','11'=>'十一月','12'=>'十二月'];
        $this->assign('month',$month);
        $this->assign('thisMonth',date("m",strtotime("last month")));
        $this->assign('history',$history);
        return $this->view->fetch();
    }
    public function history()
    {
        $id = $this->request->request('id');
        $adata = Db::name('content')->where('id',$id)->find();
        $data = json_decode($adata['data'],true);
        arsort($data['pp']);
        $this->assign('ppData',$data['pp']);
        $this->assign('pdData',$data['pd']);
        $this->assign('titel',$adata['name']);
        return $this->view->fetch();
    }
    public function list()
    {
        $url = "http://lr.huanghaipingsite.top/index/index/history?id=";
        $list = [];
        $data = Db::name('content')->order('time desc')->select();
        foreach ($data as $k => $da){
            $list[$k]['title'] = $da['name'];
            $list[$k]['link'] = $url.$da['id'];
            $mdata = json_decode($da['data'],true);
            $list[$k]['money'] = $mdata['total'];
        }
        $this->assign('list',$list);

        return $this->view->fetch();
    }

}
